<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        //方式一：
        /**function abs(x){
            if (x>0){
                return x;
            } else {
                return -x;
            }
        }*/
        // 方式二
        var abs = function(x){
            console.log("x =>"+x);
            for(var i=0;i<arguments.length;i++){
                console.log(arguments[i]);
            }
            if(typeof x !== 'number'){
                throw "Not a number!";
            }
            if (x>0){
                return x;
            } else {
                return -x;
            }
        }
    </script>
</head>
<body>

</body>
</html>